<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>onload 事件</title>
    <script>
        //监听页面加载完成
        window.onload = function(){
        console.log("页面加载完成了");
        //执行dom分配事件
        document.getElementById("btn").onclick = function () {
            console.log("helloworld");
        }
        }
    </script>
</head>
<body>
<button id="btn">点我呀</button>
</body>
</html>